<template>
	<el-dialog :title="titleMap[mode]" v-model="visible" customClass="customWidth" destroy-on-close @closed="$emit('closed')">
		<el-form :model="form" :rules="rules" ref="dialogForm" label-width="100px" label-position="left">
			
			<el-row :gutter="24"> 
				<el-col :lg="24">
					<el-form-item label="企业名称" prop="companyName"> 
						<el-input v-model="form.companyName" placeholder="企业名称" clearable maxlength="80"></el-input>
					</el-form-item>
				</el-col>
			 </el-row>
			 <el-row :gutter="24"> 
				<el-col :lg="24">
					<el-form-item label="规模类型" prop="petitor"> 
						<el-input v-model="form.petitor" placeholder="规模类型" clearable maxlength="80"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row :gutter="24"> 
				<el-col :lg="24">
					<el-form-item label="所属行业" prop="petitor"> 
						<el-input v-model="form.petitor" placeholder="所属行业" clearable maxlength="80"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row :gutter="24"> 
				<el-col :lg="24">
					<el-form-item label="企业本年度营业收入（亿元）" prop="petitor"> 
						<el-input v-model="form.petitor" placeholder="企业本年度营业收入（亿元）" clearable maxlength="80"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row :gutter="24"> 
				<el-col :lg="24">
					<el-form-item label="所需企业指标" prop="needKpi">
							<el-input type="textarea" :rows="2" maxlength="380" placeholder="所需企业指标" v-model="form.needKpi"></el-input>
					</el-form-item>
				</el-col>
			 </el-row>
			<el-row :gutter="24"> 
				<el-col :lg="12"> 
					<el-form-item label="企业所在省份" prop="urgency">
						<sc-select v-model="form.urgency" :params="{code:'supervisionLevel'}" :apiObj="$API.system.sysDic.getSysDicByCode" clearable filterable style="width: 100%"></sc-select>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row :gutter="24"> 
				<el-col :lg="12"> 
					<el-form-item label="上一年度营业收入（亿元）" prop="urgency">
						<el-input v-model="form.petitor" placeholder="年度营业收入" clearable maxlength="80"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row :gutter="24"> 
				<el-col :lg="12"> 
					<el-form-item label="本年度净利润（亿元）" prop="urgency">
						<el-input v-model="form.petitor" placeholder="净利润" clearable maxlength="80"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row :gutter="24"> 
				<el-col :lg="12"> 
					<el-form-item label="总资产（亿元）" prop="urgency">
						<el-input v-model="form.petitor" placeholder="总资产" clearable maxlength="100"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row :gutter="24"> 
				<el-col :lg="12"> 
					<el-form-item label="本年度缴纳税金（亿元）" prop="urgency">
						<el-input v-model="form.petitor" placeholder="总本年度缴纳税金资产" clearable maxlength="100"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row :gutter="24"> 
				<el-col :lg="12"> 
					<el-form-item label="本年度主营业务收入（亿元）" prop="urgency">
						<el-input v-model="form.petitor" placeholder="本年度主营业务收入" clearable maxlength="100"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			 
			<el-row :gutter="24"> 
				<el-col :lg="12"> 
					<el-form-item label="本年度负债总额" prop="urgency">
						<el-input v-model="form.petitor" placeholder="本年度负债总额" clearable maxlength="100"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row :gutter="24"> 
				<el-col :lg="12"> 
					<el-form-item label="净资产利润" prop="urgency">
						<el-input v-model="form.petitor" placeholder="净资产利润" clearable maxlength="100"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row :gutter="24"> 
				<el-col :lg="12"> 
					<el-form-item label="本年度销售总额" prop="urgency">
						<el-input v-model="form.petitor" placeholder="本年度销售总额" clearable maxlength="100"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
		<template #footer>
			<el-button @click="visible=false">取 消</el-button>
			<el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
		</template>
	</el-dialog>

</template>
<script>
import selectUserDialog from "@/views/module/selectUserDialog";
import msgBoxCheckBox from "@/views/module/msgBoxCheckBox";
import AttachMenu from '@/views/module/attachMenu'
import {defineAsyncComponent} from "vue";
const scEditor = defineAsyncComponent(() => import('@/components/scEditor'));
export default {
	emits: ['success', 'closed'],
	components: {
		msgBoxCheckBox,
		selectUserDialog,
		AttachMenu,
		scEditor
	},
	data() {
		return {
			visible: false,
			isSaveing: false,
			isShowMsg:false,
			mode: "add",
			templates: [],
			fileList:[],
			userList:[],
			apiObj:this.$API.file.attach.uploadFile,
			titleMap: {
				add: '第五指标评测信息表',
				edit: '编辑第五指标评测信息表',
			},
			form: {
				keyId:'',
				petitor: '',
				companyName: '', 
				needKpi: '', 
				urgency:''
			},
			rules: {
				companyName: [
					{required: true, message: '企业名称不能为空', trigger: 'blur'}
				],
				petitor: [
					{required: true, message: '申请人不能为空', trigger: 'blur'}
				],
				needKpi: [
					{required: true, message: '所需企业指标不能为空', trigger: 'blur'}
				],
				urgency: [
					{required: true, message: '紧急程度', trigger: 'blur'}
				] 
			}
		}
	},
	mounted() {
		this.getSupervisionLeadList();
	},
	methods: {
		//显示
		open(mode = 'add') {
			this.mode = mode;
			this.visible = true;
			return this
		},
		publishDateAfter(time){
			return time.getTime()<(Date.now()-24*60*60*1000)
		},
		async getSupervisionLeadList(){
			let res = await this.$API.supervision.supervisionConfig.getSupervisionLeadList.get();
			if (res.code == 200) {
				this.userList = res.data;
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		submit() {
			this.$refs.dialogForm.validate(async (valid) => {
				if (valid) {
					this.isSaveing = true;
					var res;
					if (this.mode == "add") {
						res = await this.$API.supervision.supervision.insertSupervision.post(this.form);
					} else if (this.mode == "edit") {
						res = await this.$API.supervision.supervision.updateSupervision.post(this.form);
					}
					this.isSaveing = false;
					if (res.code == 200) {
						this.$emit('success')
						this.visible = false;
						this.$message.success("操作成功")
					} else {
						this.$alert(res.message, "提示", {type: 'error'})
					}
				}
			})
		},
		setData(data) { 
			this.form.urgency = data.urgency
			this.form.companyName = data.companyName
			this.form.needKpi = data.needKpi
			this.form.petitor = data.petitor
		},
		addNewFile(res, file)
		{
			let tArr = this.form.attachId.split(",");
			tArr.push(res.data.attachId);
			this.form.attachId = tArr.join(",");
		},
		addNewFile1(res, file)
		{
			let tArr = this.form.attachId1.split(",");
			tArr.push(res.data.attachId1);
			this.form.attachId1 = tArr.join(",");
		}
	}
}
</script>

<style>
.customWidth {
	/*width: 60%;*/
	widows: 400px;
}
</style>
